package course.myset;

import java.util.Comparator;
import java.util.TreeSet;

public class MyTreeSet5 {
    public static void main(String[] args) {
        TreeSet<String> ts = new TreeSet<>(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                int length = o1.length() - o2.length();
                length = length == 0?o1.compareTo(o2):length;
                return length;
            }
        });

        ts.add("a");
        ts.add("ac");
        ts.add("ba");
        ts.add("aaaa");

        System.out.println(ts);

    }
}
